feat: add data migration to sync DiscussionsConfiguration with modulestore tab.is_hidden#38294
feat: add data migration to sync DiscussionsConfiguration with modulestore tab.is_hidden#38294Anas12091101 wants to merge 3 commits intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @Anas12091101! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
openedx/core/djangoapps/discussions/migrations/0019_sync_discussion_config_enabled_with_tab.py
Show resolved
Hide resolved
…store tab.is_hidden
ff22569 to
f07de7f
Compare
openedx/core/djangoapps/discussions/migrations/0019_sync_discussion_config_enabled_with_tab.py
Show resolved
Hide resolved
openedx/core/djangoapps/discussions/migrations/0019_sync_discussion_config_enabled_with_tab.py
Show resolved
Hide resolved
kdmccormick
left a comment
There was a problem hiding this comment.
just a couple requests, looks good otherwise.
| # Also update CourseAppStatus to keep the Pages & Resources UI in sync. | ||
| # The update_course_apps_status task may run before this handler due to | ||
| # the COURSE_PUBLISH_TASK_DELAY countdown, caching a stale enabled value. |
There was a problem hiding this comment.
I have added the code here. We have 2 scenarios:
New course: No CourseAppStatus row exists yet. The handler creates one with the correct enabled value.
Old course: A CourseAppStatus row already exists (created by update_course_apps_status on a previous publish, or by initialize_course_app_status on first MFE page load). The handler updates it.
could you add an assertion for each of those scenarios into https://github.com/openedx/openedx-platform/blob/master/openedx/core/djangoapps/discussions/tests/test_handlers.py ?
| """ | ||
| Sync DiscussionsConfiguration.enabled and CourseAppStatus.enabled with | ||
| CourseOverviewTab.is_hidden. | ||
|
|
||
| When a course is imported, the discussion tab's is_hidden value is carried over | ||
| from the source course. However, DiscussionsConfiguration.enabled and | ||
| CourseAppStatus.enabled default to True and are not updated from the imported | ||
| tab state, causing a desync. | ||
|
|
||
| This migration reads each discussion tab from CourseOverviewTab (a DB cache of | ||
| course tabs) and sets both DiscussionsConfiguration.enabled and | ||
| CourseAppStatus.enabled to NOT is_hidden. | ||
| """ |
There was a problem hiding this comment.
could you clarify that this is a backfill for existing courses, whereas the sync going forward is handled by update_course_discussion_config ?
Description
We introduced a fix in #38084 to synchronize DiscussionsConfiguration.enabled (DB) with tab.is_hidden (modulestore) during course imports. While this resolves the issue for newly imported courses, existing courses that are currently out of sync still need to be updated so that course authors see the correct values.
This PR adds a data migration that reads each course's discussion tab from
CourseOverviewTab(a DB-level cache of modulestore tabs) and updates bothDiscussionsConfiguration.enabledandCourseAppStatus.enabledto match (enabled = NOT is_hidden). Only out-of-sync rows are updated. The migration usesCourseOverviewTabinstead of the modulestore directly to avoid performance issues at scale.Useful information to include:
changes.
Supporting information
#38084 (comment)
Testing instructions
Visit the
Pages and Resourcespage in the authoring MFE and verify that the discussion configuration is unsyncedRun the migration:
Deadline
"None"
Other information
Include anything else that will help reviewers and consumers understand the change.